import request from '@/utils/request';

/**
 * 分页查询用户
 */
export async function get_list(params) {
  const res = await request.post('/purchase/receipts_purchase/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取大类列表 */
export async function get_broad_class_list(params) {
  const res = await request.post('/material/broad_class/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取仓库列表 */
export async function get_warehouse_list(params) {
  const res = await request.post('/material/warehouse/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取报损列表 */
export async function get_receipts_cause(params) {
  const res = await request.post('/purchase/receipts_cause/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.data
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取门店列表 */
export async function get_store_list(params) {
  const res = await request.post('/tenant/store/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取门店柜组列表 */
export async function get_store_group_list(params) {
  const res = await request.post('/material/store_group/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取门店品牌列表 */
export async function get_store_brand_list(params) {
  const res = await request.post('/material/store_brand/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取经营品牌列表 */
export async function get_brand_list(params) {
  const res = await request.post('/material/brand/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取总店员工列表 */
export async function get_user_list(params) {
  const res = await request.post('/user/user/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取货品类别 */
export async function get_subclass_list(params) {
  const res = await request.post('/material/subclass/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取货品成色 */
export async function get_quality_list(params) {
  const res = await request.post('/material/quality/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取货品款式列表 */
export async function get_style_list(params) {
  const res = await request.post('/material/style/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取供应商列表 */
export async function get_supplier_list(params) {
  const res = await request.post('/material/supplier/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取供应商款号列表 */
export async function get_supplier_style_list(params) {
  const res = await request.post('/material/supplier_style/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}

/* 获取系列名称列表 */
export async function get_series_list(params) {
  const res = await request.post('/material/series/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取系列款式列表 */
export async function get_series_style_list(params) {
  const res = await request.post('/material/series_style/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取赠品类型列表 */
export async function get_gift_list(params) {
  const res = await request.post('/material/gift/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取工艺类型列表 */
export async function get_technology_list(params) {
  const res = await request.post('/material/technology/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取货品品类列表 */
export async function get_classes_list(params) {
  const res = await request.post('/material/classes/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取价格类型列表 */
export async function get_price_category_list(params) {
  const res = await request.post('/material/price_category/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取宝石列表 */
export async function get_gem_category_list(params) {
  const res = await request.post('/material/gem_category/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取贵金属列表 */
export async function get_metal_color_list(params) {
  const res = await request.post('/material/metal_color/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取财务分类列表 */
export async function get_finance_list(params) {
  const res = await request.post('/material/finance/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取工费类型列表 */
export async function get_labor_category_list(params) {
  const res = await request.post('/material/labor_category/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取宝石属性列表 */
export async function get_gem_attribute_list(params) {
  const res = await request.post('/material/gem_attribute/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 获取石重范围 */
export async function get_stone_weight_list(params) {
  const res = await request.post('/material/stone_weight/get_list', {
    ...params
  });
  if (res.data.code === 1) {
    return {
      list: res.data.data.row_list,
      columns: res.data.data.columns,
      searchData: res.data.data.search_area,
      count: res.data.data.page_info?.total,
      top_button: res.data.data.top_button
    };
  }
  return Promise.reject(res.data.msg);
}
/* 采购单详情 */
export async function receipts_purchase_detail(params) {
  const res = await request.post('/purchase/receipts_purchase/detail', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
/* 作废 */
export async function cancel_purchase(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/cancel_purchase',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 删除 */
export async function del_receipts(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/del_receipts',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 反审 */
export async function back_verify(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/back_verify',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 取消审核 */
export async function cancel_verify(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/cancel_verify',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 提交审核 */
export async function confirm_purchase(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/confirm_purchase',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 添加货品 */
export async function add_goods(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/add_goods',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 货品详情 */
export async function goods_detail(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/goods_detail',
    params
  );
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}

/* 下载模板 */
export async function download_import_template_purchase(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/import_template_purchase',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}

/* 删除货品 */
export async function del_goods(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/del_goods',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 编辑货品 */
export async function edit_goods(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/edit_goods',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 导出 */
export async function purchase_export(params) {
  const res = await request.post('/purchase/receipts_purchase/export', params);
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 上传货品 */
export async function import_goods_purchase(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/import_goods_purchase',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 单据模板  1首饰采购2饰品采购3总店返厂4门店返厂5旧货转成品6分配出库7调拨出库8回仓出库 */
export async function receipts_templete(params) {
  const res = await request.post(
    '/material/receipts_templete/get_list',
    params
  );
  if (res.data.code === 1) {
    return res.data;
  }
  return Promise.reject(res.data.msg);
}
/* 金料类型 */
export async function get_gold_list(params) {
  const res = await request.post('/material/gold_category/get_list', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}

/* 货品模板字段 */
export async function get_column_templete_list(params) {
  const res = await request.post('/material/column_templete/get_list', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}

/* 货品模板字段 */
export async function export_goods(params) {
  const res = await request.post(
    '/purchase/receipts_purchase/export_goods',
    params
  );
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}

/* 多图上传 */
export async function uploadBatch(params) {
  const res = await request.post('/system/basic/uploadBatch', params);
  if (res.data.code === 1) {
    return res.data.data;
  }
  return Promise.reject(res.data.msg);
}
